<template>
    <div>
        <router-link tag="div" to="/" class="header-abs" v-show="showABS">
            <div class="iconfont back-icon">&#xe624;</div>
        </router-link>
        <div class="header-fixed" v-show="!showABS" :style="opacityStylr">
            <router-link to="/">
                <div class="iconfont header-back">&#xe624;</div>
            </router-link>
            城市详情
        </div>
    </div>
</template>

<script>
//import  from ' '
export default {
    components: {},
    data() {
        return {
            showABS: true,
            opacityStylr: {
                opacity:0
            }
        };
    },
    methods: {
        handleScroll () {
            let top = document.documentElement.scrollTop || document.body.scrollTop || window.pageYOffset
            if (top>60) {
                let opacity = top / 140
                opacity = opacity > 1 ? 1 : opacity
                this.opacityStylr = {
                    opacity
                }
                this.showABS = false
            }else{
                this.showABS = true
            }
        }
    },
    mounted () {
        window.addEventListener('scroll' , this.handleScroll)
    },
    destroyed () {
        window.removeEventListener('scroll' , this.handleScroll)
    }
    }
</script>
<style lang='stylus' scoped>
@import '~styles/varibles.styl'
    .header-abs
        position absolute
        left .2rem
        top .2rem
        width .8rem
        height .8rem
        line-height .8rem
        text-align center
        border-radius .4rem
        background rgba(0 , 0 , 0 , .8)
        .iconfont
            color #fff
            font-size .4rem
    .header-fixed
        z-index 2
        position: fixed
        top 0
        left 0
        right 0
        height: .86rem
        line-height: .86rem
        text-align: center 
        color: #fff
        background-color: $bgColor
        font-size: .32rem
        .header-back
            position: absolute 
            top: 0
            left: 0
            width: .64rem
            text-alirn: center 
            font-size: .4rem
            color: #fff
</style>